﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Contract.ascx.cs" Inherits="ERP.Modules.Contract" %>
<%-------------------------------%>
<ext:Hidden ID="FormatTypeContract" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelContract">
    <Content>
        <%--------------GridContract-----------------%>
        <ext:GridPanel
            ID="grContract"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <%-------------StoreContract-----------------%>
                <ext:Store
                    ID="StoreContract"
                    runat="server"
                    OnReadData="StoreContract_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="Contract_ID" GroupField="TypeContract_Name">
                            <Fields>
                                <ext:ModelField Name="Contract_Code" Type="String" />
                                <ext:ModelField Name="DateBegin" Type="Date" />
                                <ext:ModelField Name="TypeContract_Name" Type="String" />
                                <ext:ModelField Name="Bank_Code" Type="String" />
                                <ext:ModelField Name="FullName" Type="String" />
                                <ext:ModelField Name="Job_Name_Emp" Type="String" />
                                <ext:ModelField Name="Contract_DateBegin" Type="String" />
                                <ext:ModelField Name="Contract_DateEnd" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Số HĐ" Width="100" DataIndex="Contract_Code"/>
                    <ext:DateColumn runat="server" Text="Ngày lập" Width="136" DataIndex="DateBegin" Format="dd-MM-yyyy" Align="Center"/>
                    <ext:Column runat="server" Text="Loại hợp đồng" Width="100" DataIndex="TypeContract_Name"/>
                    <ext:Column runat="server" Text="Mã nhân viên" Width="100" DataIndex="Bank_Code"/>
                    <ext:Column runat="server" Text="Tên nhân viên" Width="200" DataIndex="FullName"/>
                    <ext:Column runat="server" Text="Chức vụ" Width="81" DataIndex="Job_Name_Emp"/>
                    <ext:DateColumn runat="server" Text="Ngày hiệu lực" Width="136" DataIndex="Contract_DateBegin" Format="dd-MM-yyyy" Align="Center"/>
                    <ext:DateColumn runat="server" Text="Ngày kết thúc" Width="136" DataIndex="Contract_DateEnd" Format="dd-MM-yyyy" Align="Center" Flex="1"/>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server"
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="ContractDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Contract_ID" Value="record.data.Contract_ID" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                     <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grContract}, #{FormatTypeContract}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar runat="server" StoreID="StoreContract" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsContract-----------------%>
        <ext:Window ID="WindowsContract" runat="server"
            Title="Hợp đồng lao động"
            DefaultAnchor="100%"
            Width="866"
            Height="521"
            Hidden="true"
            AutoDataBind="True"
            Region="Center"
            Resizable="False"
            Modal="true"
            HideMode="Offsets"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelContract}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="lbID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelContract" runat="server"
                    AutoHeight="true"
                    BodyPadding="10"
                    Frame="True"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:FieldContainer
                                    runat="server"
                                    AnchorHorizontal="100%"
                                    Layout="HBoxLayout">
                                    <Items>
                                        <ext:TextField ID="txtContract_Code" runat="server" FieldLabel="Số HĐ" LabelWidth="80" Width="250" AllowBlank="false" MarginSpec="0 20 5 0" />
                                        <ext:SelectBox
                                            ID="SelectBoxTypeContract"
                                            runat="server"
                                            Cls="x-select-box"
                                            LabelWidth="87"
                                            FieldLabel="Loại hợp đồng"
                                            DisplayField="TypeContract_Name"
                                            ValueField="TypeContract_ID"
                                            MarginSpec="0 3 5 0"
                                            Width="250"
                                            AllowBlank="False"
                                            EmptyText="Chọn loại hợp đồng">
                                            <Store>
                                                <ext:Store ID="StoreContractType" runat="server">
                                                    <Model>
                                                        <ext:Model runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="TypeContract_Name" />
                                                                <ext:ModelField Name="TypeContract_ID" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:SelectBox>
                                        <ext:Button runat="server" Text="" Icon="Reload" ID="btnReloadCode" ToolTip="Click vào để tải lại danh sách" Margins="0 10 0 0">
                                            <DirectEvents>
                                                <Click OnEvent="btnReloadCode_Click">
                                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:DateField ID="txtDateBegin" runat="server" FieldLabel="Ngày lập" Width="252" AllowBlank="false" MarginSpec="0 20 5 0" />
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                        </ext:FieldContainer>
                        <ext:TabPanel ID="TabPanelMain" runat="server" Layout="Fit">
                            <Items>
                                <ext:Panel 
                                    ID="TabInfoCompany"
                                    runat="server" 
                                    Title="Đại diện Cty" 
                                    Height="350"
                                    Layout="FormLayout"
                                    Border="False"
                                    BodyPadding="6">
                                    <Items>
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtContract_Name" runat="server" FieldLabel="Ông/bà" AnchorHorizontal="100%" AllowBlank="false" MarginSpec="0 20 5 0" />
                                                <ext:TextField ID="txtContract_Job" runat="server" FieldLabel="Chức vụ" Width="273" AllowBlank="false" MarginSpec="0 20 5 0" />
                                                <ext:TextField ID="txtContract_National" runat="server" FieldLabel="Quốc tịch" Width="240" AllowBlank="false"/>
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtContract_Identification" runat="server" FieldLabel="CMND" AnchorHorizontal="100%" AllowBlank="false" MarginSpec="0 20 5 0" />
                                                <ext:TextField ID="txtContract_Company" runat="server" FieldLabel="Đại diện cho" Width="533" AllowBlank="false" />
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                 <ext:TextField ID="txtContract_Address" runat="server" FieldLabel="Địa chỉ" Width="806" AllowBlank="false" MarginSpec="0 20 5 0" />
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtContract_Phone" runat="server" FieldLabel="Điện thoại" Width="252" AllowBlank="false" MarginSpec="0 20 5 0" />
                                                <ext:TextField ID="txtContract_Fax" runat="server" FieldLabel="Số Fax" Width="275" MarginSpec="0 5 5 0" AllowBlank="false" />
                                            </Items>
                                        </ext:FieldContainer>
                                    </Items>
                                </ext:Panel>
                                <ext:Panel 
                                    ID="TabInfo"
                                    runat="server" 
                                    Title="Đối tượng hợp đồng" 
                                    Height="350"
                                    Layout="FormLayout"
                                    Border="False"
                                    BodyPadding="6">
                                    <Items>
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtFullName" runat="server" FieldLabel="Họ tên" LabelWidth="150" Width="308" AllowBlank="false" MarginSpec="0 5 5 0"  ReadOnly="True" />
                                                <ext:Button runat="server" Text="" Icon="BulletGet" ID="btnEmployee" ToolTip="Click vào để chọn đối tượng" Margins="0 20 0 0">
                                                    <DirectEvents>
                                                        <Click OnEvent="btnEmployee_Click">
                                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                                <ext:TextField ID="txtEmployee_ID" runat="server" FieldLabel="Employee_ID" AnchorHorizontal="100%" AllowBlank="false" Hidden="True" />
                                                <ext:DateField ID="txtBrithday" runat="server" FieldLabel="Ngày sinh" Width="252" AllowBlank="True" MarginSpec="0 20 5 0" ReadOnly="True" />
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:TextField ID="txtEducationalLevel" runat="server" FieldLabel="Trình độ văn hoá" Width="608" LabelWidth="150" AllowBlank="True" MarginSpec="0 20 5 0" ReadOnly="True"  />
                                        <ext:TextField ID="txtJob_Name_Emp" runat="server" FieldLabel="Nghề nghiệp" Width="608" LabelWidth="150" AllowBlank="True" MarginSpec="0 20 5 0" ReadOnly="True"/>
                                        <ext:TextField ID="txtCMND" runat="server" FieldLabel="CMND" LabelWidth="150" Width="608" AllowBlank="True" MarginSpec="0 20 5 0" ReadOnly="True"/>
                                        <ext:TextField ID="txtAddress_Emp" runat="server" FieldLabel="Địa chỉ" LabelWidth="150" Width="608" AllowBlank="True" ReadOnly="True"/>
                                    </Items>
                                </ext:Panel>
                                <ext:Panel 
                                    ID="TabContent"
                                    runat="server" 
                                    Title="Nội dung hợp đồng" 
                                    Height="350"
                                    Border="False"
                                    BodyPadding="6">
                                    <Items>
                                        <ext:NumberField ID="txtContract_TimeWork" runat="server" FieldLabel="Giờ làm việc" Width="265" LabelWidth="150" AllowBlank="false" MarginSpec="0 20 5 0" MinValue="0"  />
                                        <ext:SelectBox
                                            ID="SelectBoxContractJob"
                                            runat="server"
                                            Cls="x-select-box"
                                            LabelWidth="150"
                                            FieldLabel="Chức vụ"
                                            DisplayField="Job_Name"
                                            ValueField="Job_ID"
                                            MarginSpec="8 3 5 0"
                                            Width="265"
                                            AllowBlank="False"
                                            EmptyText="Chọn chức vụ">
                                            <Store>
                                                <ext:Store ID="StoreContractJob" runat="server">
                                                    <Model>
                                                        <ext:Model runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="Job_Name" />
                                                                <ext:ModelField Name="Job_ID" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:SelectBox>
                                        <ext:NumberField ID="txtContract_Wage" runat="server" FieldLabel="Mức lương" Width="265" LabelWidth="150" AllowBlank="false" MarginSpec="0 20 5 0"  />
                                        <ext:NumberField ID="txtContract_Vacation" runat="server" FieldLabel="Số ngày nghỉ được hưởng lương" Width="265" LabelWidth="150" AllowBlank="false" MarginSpec="0 20 5 0"  />
                                        <ext:TextArea ID="txtContract_Interest" runat="server" FieldLabel="Phúc lợi" Width="690" Height="50" LabelWidth="150" MarginSpec="0 20 5 0"  />
                                        <ext:DateField ID="txtContract_DateBegin" runat="server" FieldLabel="Từ ngày" LabelWidth="150" Width="265" AllowBlank="false" MarginSpec="0 20 5 0" />
                                        <ext:DateField ID="txtContract_DateEnd" runat="server" FieldLabel="Đến ngày" LabelWidth="150" Width="265" AllowBlank="false" />
                                    </Items>
                                </ext:Panel>
                            </Items>
                        </ext:TabPanel>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <%--------------Employee-----------------%>
        <ext:Window ID="WindowContractEmployee" runat="server"
            Title="Thông tin nhân viên"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grContractEmployee"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <%--------------StoreContractEmployee-----------------%>
                        <ext:Store
                            ID="StoreContractEmployee"
                            runat="server"
                            OnReadData="StoreContractEmployee_RefreshData"
                            PageSize="14">
                            <Model>
                                <ext:Model runat="server" IDProperty="Employee_Id">
                                    <Fields>
                                        <ext:ModelField Name="Bank_Code" Type="String" />
                                        <ext:ModelField Name="FullName" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Mã nhân viên" Width="100" DataIndex="Bank_Code" Align="Center"/>
                            <ext:Column runat="server" Text="Tên nhân viên" Width="150" DataIndex="FullName" Flex="1"/>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                            <DirectEvents>
                                <Select OnEvent="CellContractEmployee_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchContractEmployee" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="ContractEmployee_Event"></TriggerClick>
                                        <KeyPress OnEvent="ContractEmployee_Event"></KeyPress>
                                        <KeyUp OnEvent="ContractEmployee_Event"></KeyUp>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar runat="server" StoreID="StoreContractEmployee" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
    </Content>
</ext:Panel>